let startWorkSeconds = 0
let endWorkSeconds = 24 * 60 * 60
if (workingHours) {
    startWorkSeconds = workingHours.startHours * 60 * 60 + workingHours.startMinutes * 60
    endWorkSeconds = workingHours.endHours * 60 * 60 + workingHours.endMinutes * 60
}

for (const schedule of scheduleList) {
    let xShow = false
    let yShow = false
    if ((schedule.x + schedule.width) > offsetX && schedule.x < (offsetX + width)) {
        xShow = true
    }
    if ((schedule.y + schedule.height) > offsetY && schedule.y < (offsetY + height)) {
        yShow = true
    }

    if (workingHours) {
        const startSeconds = getTimeDetail(schedule.startTime).seconds
        const endSeconds = getTimeDetail(schedule.endTime).seconds
        xShow = xShow && checkInside(startSeconds) || checkInside(endSeconds)
    }

    schedule.show = xShow && yShow
}

function checkInside(seconds) {
    return seconds >= startWorkSeconds && seconds <= endWorkSeconds
}

function getTimeDetail(time) {
    const timeOffset = (time - todayTime + dayTimeOffset)
    const day = Math.floor(timeOffset / daySeconds)
    const seconds = timeOffset % daySeconds
    return { day, seconds }
}

return {
    scheduleList: scheduleList.filter(item => item.show)
};